package cn.it.shop.service.impl;

import javax.annotation.Resource;

import org.hibernate.classic.Session;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import cn.it.shop.dao.AccountDao;
import cn.it.shop.pojo.Account;
import cn.it.shop.service.AccountService;

@Service(value="accountService")// 如果没有取名称默认就是accountServiceImpl
public class AccountServiceImpl extends BaseServiceImpl<Account> implements UserDetailsService,AccountService{
	
	/*
	 * 根据用户名,查询当前用户信息,和它角色信息, 被查询的类必须实现UserDetails接口 此操作在项目中应该放到登陆成功之后调用
	 */
	@Override
	public UserDetails loadUserByUsername(String login)
			throws UsernameNotFoundException {
		return accountDao.loadUserByUsername(login);
	}
	
	@Override
	public Account login(Account account) {
		return accountDao.login(account);
	}

	@Override
	public void updateOnlyAccount(Account account) {
		accountDao.updateOnlyAccount(account);
	}

	@Override
	public Account getFetchRid(int id) {
		return accountDao.getFetchRid(id);
	}
}
